package com.blb.edusearchservice.controller;

import com.blb.common.entity.Course;
import com.blb.common.entity.PageEntity;
import com.blb.common.entity.ResponseResult;
import com.blb.edusearchservice.service.CourseIndexService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
public class CourseIndexController {

    @Resource
    private CourseIndexService courseIndexService;

    @GetMapping("search/init-course-index")
    public ResponseResult<String> initCourseIndex(){
        courseIndexService.initCourseIndex();
        return ResponseResult.ok("ok");
    }

    @RequestMapping("search/course")
    public ResponseResult<PageEntity> searchCourse(@RequestBody Map<String,String> map){
        PageEntity<Course> pageEntity = courseIndexService.searchCourse(map);
        return ResponseResult.ok(pageEntity);
    }
}
